package com.catering.controller;

import com.catering.pojo.DVoucher;
import com.catering.service.DVoucherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/voucher")
public class DVoucherController {
    @Autowired
    private DVoucherService dVoucherService;
    @RequestMapping("ByDVoucher")
    public List<DVoucher> selectByDVoucher(Integer uid){
        return dVoucherService.selectByDVoucher(uid);
    }
    @RequestMapping("ByEffective")
//    查询优惠卷
    public List<DVoucher> selectByEffective(){
        return dVoucherService.selectByEffective();
    }
    @RequestMapping("updateByEffective")
//    领取优惠卷
    public void updateByEffective(@RequestParam("uid")Integer uid,@RequestParam("vid") Integer vid){
        dVoucherService.updateByEffective(uid,vid);
    }
//    使用优惠卷
    @RequestMapping("updateByEffective1")
    public void updateByEffective1(@RequestParam("vid") Integer vid){
        dVoucherService.updateByEffective1(vid);
    }
}
